#include "dexgel\dexgel.hpp"


#include <vector>
#pragma comment(lib, "dexgel.lib")

#define PACKRGB(r,g,b) \
	((unsigned int)((((0xff)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))

int main()
{

	float xres = 600;
	float yres = 600;
	dexgel::Window App( (int)xres, (int)yres, "TorApp");

	dexgel::Rendrer *rend = App.getRendrer();

	std::vector<dexgel::VertexUV> verts;
	dexgel::VertexUV v0 = {-0.5f, -0.5f,0.0f, 0.0f, 1.0f };

	dexgel::VertexUV v1 = {+0.5f, -0.5f,0.0f, 1.0f, 1.0f };

	dexgel::VertexUV v2 = {+0.5f, +0.5f,0.0f, 1.0f, 0.0f };

	dexgel::VertexUV v3 = {+0.5f, +0.5f,0.0f, 1.0f, 0.0f };

	dexgel::VertexUV v4 = {-0.5f, +0.5f,0.0f, 0.0f, 0.0f };

	dexgel::VertexUV v5 = {-0.5f, -0.5f,0.0f, 0.0f, 1.0f };

	verts.push_back( v0 );
	verts.push_back( v1 );
	verts.push_back( v2 );

	verts.push_back( v3 );
	verts.push_back( v4 );
	verts.push_back( v5 );

	dexgel::Texture *tex = rend->loadTexture("Texture.bmp");
	assert( tex != NULL );


	while( App.IsOpened() )
	{
		App.UpdateMessages();

		if( App.canRender() )
		{
			rend->begin(); // Begin the scene
			rend->disableLighting();
			tex->select();
			rend->render( &verts[0], verts.size()/3 ); 
			rend->end(); // Begin the scene
		}
	}
	delete tex;
	return EXIT_SUCCESS;
}